﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="SendM.aspx.cs" Inherits="TCS.Web.Admin.Accounts.SendM" %>
<%@ Register Src="~/uc/ucLiteral.ascx" TagName="Literal" TagPrefix="uc" %>
<%@ Register Src="~/uc/selectarea.ascx" TagName="SelectArea" TagPrefix="ucArea" %>
<%@ Register Src="~/Admin/uc/AdminMapPath.ascx" TagName="MapPath" TagPrefix="uc1" %>
<%@ Register Src="../../Controls/checkright.ascx" TagName="checkright" TagPrefix="uc2" %>
<%@ Register TagPrefix="ftb" Namespace="FreeTextBoxControls" Assembly="FreeTextBox" %>
<%@ Register Src="~/Controls/copyright.ascx" TagName="CopyRight" TagPrefix="uc1" %>
<%@ Register TagPrefix="cc1" Namespace="LtpPageControl" Assembly="LtpPageControl" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>用户组管理</title>
     <style type="text/css">
        html, body
        {
            height: 100%;
        }
        body
        {
            margin-left: 0px;
            margin-top: 0px;
            margin-right: 0px;
            margin-bottom: 0px;
            padding: 0px;
			background-color:#F4FBFF;
        }
        .savebtn
        {width:69px;   background:url(../images/anniou_14.gif) no-repeat left top;  border:none;  height:22px; }
         .returnbtn
        { width:69px; background:url(../images/anniou_16.gif) no-repeat left top;   border:none; height:22px; }
     </style>
    <link href="../css/text.css" rel="stylesheet" type="text/css" />

    <script src="../../js/jquery-1.4.1.min.js" type="text/javascript"></script>

    <script src="../../js/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <script type="text/javascript">
       
    </script>
</head>
<body onload="BindDropGroup()">
    <form id="form1" name="form1" runat="server" class="form1">
   
       <table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">
            <tr>
                <td bgcolor='<%=Application[Session["Style"].ToString()+"xtable_bgcolor"]%>'>
                    <table width="100%" border="0" cellpadding="0" cellspacing="1"
                        bordercolorlight='<%=Application[Session["Style"].ToString()+"xtable_bordercolorlight"]%>' bordercolordark='<%=Application[Session["Style"].ToString()+"xtable_bordercolordark"]%>' bgcolor="#afc4e3">
                        <tr bgcolor="#e4e4e4">
                            <td height="22" align="center" bgcolor='<%=Application[Session["Style"].ToString()+"xtable_titlebgcolor"]%>' class="bj"><strong>
                              用户短信群发</strong></td>
                        </tr>
                        <tr>
                            <td height="30" bgcolor="#F4FBFF">
                                <table cellspacing="0" cellpadding="0" width="100%" border="0">
                                    <tbody>
                                        <tr>
                                            <td height="25" width="20%" align="right">
                                                所属行政区 ：
                                            </td>
                                            <td height="25" width="*" align="left">
                                                <span style="display:none">  <ucArea:SelectArea ID="droptest" Onclick="BindDropGroup()" runat="server" /></span>
                                                <uc:Literal ID="literal1" runat="server"></uc:Literal>
                                                系统用户分组 ：<select id="dropGroup" name="dropGroup" runat="server">
                                                </select>&nbsp;&nbsp;&nbsp;&nbsp;
                                                <button id="btn" onclick="return BindUserSubScript()" title="确定">
                                                    .确定.
                                                </button>
                                            </td>
                                        </tr>
                                     
                                    </tbody>
                              </table>
                          </td>
                        </tr>
                        <tr id="trSelect">
                            <td height="22" bgcolor="#F4FBFF">
                                <table width="100%" height="100%" border="0" cellpadding="5" cellspacing="0" align="center">
                                    <tr>
                                        <td valign="top">
                                            <table width="200" border="0" cellpadding="0" cellspacing="0" align="center">
                                                <tr align="middle">
                                                    <td id="tdpeople" align="middle" valign="center">
                                                        全体人员
                                                    </td>
                                                </tr>
                                                <tr align="middle">
                                                    <td align="middle" valign="top">
                                                        <select id="selepeople" ondblclick='selectpeople()' multiple size="14" align="center"
                                                            style=" border-style:inset; border-color:ThreeDShadow; border-width: 1px; width: 100%; height: 187px">
                                                        </select>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                        <td valign="top">
                                            <table class="buttontable" width="96" height="220" border="0" cellpadding="0" cellspacing="0"
                                                align="center" valign="center">
                                                <tr class="buttonallshare" valign="center">
                                                    <td align="middle" valign="center">
                                                        <a onclick="return selectallpeople()" id="dbrightarrow" name="dbrightarrow"><span
                                                            lang="EN-US" style="font-size: 20pt; cursor: hand; color: #99CC00; font-family: Webdings;
                                                            mso-bidi-font-size: 12.0pt; mso-ascii-font-family: 'Times New Roman'; mso-fareast-font-family: 宋体;
                                                            mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';
                                                            mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN;
                                                            mso-bidi-language: AR-SA; mso-char-type: symbol; mso-symbol-font-family: Webdings">
                                                            <span style="cursor: hand; color: #3366cc; mso-char-type: symbol; mso-symbol-font-family: Webdings">
                                                                :</span></span> </a>
                                                    </td>
                                                </tr>
                                                <tr class="buttonshare">
                                                    <td align="middle" valign="center">
                                                        <a name="rightarrow" id="rightarrow" style="color: #3366cc" onclick="return selectpeople()">
                                                            <span lang="EN-US" style="font-size: 20pt; cursor: hand; font-family: Webdings; mso-bidi-font-size: 12.0pt;
                                                                mso-ascii-font-family: 'Times                     
												 New Roman'; mso-fareast-font-family: 宋体; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';
                                                                mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN;
                                                                mso-bidi-language: AR-SA; mso-char-type: symbol; mso-symbol-font-family: Webdings">
                                                                <span style="cursor: hand; mso-char-type: symbol; mso-symbol-font-family: Webdings">
                                                                    4</span></span> </a>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <hr style="width: 100%; color: #3366cc; height: 2px" size="2">
                                                    </td>
                                                </tr>
                                                <tr class="buttoncancel">
                                                    <td align="middle" valign="center">
                                                        <a name="leftarrow" id="leftarrow" style="color: #3366cc" onclick="return cancelpeople()">
                                                            <span lang="EN-US" style="font-size: 20pt; cursor: hand; font-family: Webdings; mso-bidi-font-size: 12.0pt;
                                                                mso-ascii-font-family: 'Times New Roman'; mso-fareast-font-family: 宋体; mso-hansi-font-family: 'Times New Roman';
                                                                mso-bidi-font-family: 'Times New Roman'; mso-font-kerning: 1.0pt; mso-ansi-language: EN-US;
                                                                mso-fareast-language: ZH-CN; mso-bidi-language: AR-SA; mso-char-type: symbol;
                                                                mso-symbol-font-family: Webdings"><span style="cursor: hand; mso-char-type: symbol;
                                                                    mso-symbol-font-family: Webdings">3</span></span> </a>
                                                    </td>
                                                </tr>
                                                <tr class="buttonallcancel">
                                                    <td align="middle" valign="center">
                                                        <a onclick="return cancelallpeople()" id="dbleftarrow" name="dbleftarrow"><span lang="EN-US"
                                                            style="font-size: 20pt; cursor: hand; color: #3366cc; font-family: Webdings;
                                                            mso-bidi-font-size: 12.0pt; mso-ascii-font-family: 'Times New Roman'; mso-fareast-font-family: 宋体;
                                                            mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 'Times New Roman';
                                                            mso-font-kerning: 1.0pt; mso-ansi-language: EN-US; mso-fareast-language: ZH-CN;
                                                            mso-bidi-language: AR-SA; mso-char-type: symbol; mso-symbol-font-family: Webdings">
                                                            <span style="cursor: hand; color: #3366cc; mso-char-type: symbol; mso-symbol-font-family: Webdings">
                                                                9</span></span> </a>
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                        <td valign="top">
                                            <table class="selectedpeople" id="selectedpeople" width="200" border="0" cellpadding="0"
                                                cellspacing="0" align="center">
                                                <tr id="renyuan" align="middle">
                                                    <td id="tdrole" align="middle" valign="center">
                                                        选定的人员:
                                                    </td>
                                                </tr>
                                                <tr align="middle">
                                                    <td align="middle" valign="top">
                                                        <select id="selerpeople" runat="server"  ondblclick='cancelpeople()' multiple size="14" align="center"
                                                           style=" border-style:inset; border-color:ThreeDShadow; border-width: 1px; width: 100%; height: 187px">
                                                        </select> 
                                                    </td>
                                                </tr>
                                            </table>
                                        </td>
                                    </tr>
                              </table>
                          </td>
                        </tr>
                         <tr id="trMessage" style="display:none">
                            <td bgcolor="#F4FBFF">
                                短信内容：
                                  <asp:TextBox ID="txtMsg" runat="server" TextMode="MultiLine"  MaxLength="60" onpropertychange="checklen(this)"
                                    Height="134px" Width="361px"></asp:TextBox> <span id="tno">60</span>
                           </td>
                        </tr>
                        <tr id="trNext">
                          <td height="30" align="center" bgcolor="#F4FBFF"> <button id="btnNext"   onclick="return NextStep()">下一步</button>  </td>
                        </tr>
                        <tr id="trSave" style="display:none">
                            <td height="22" bgcolor="#F4FBFF">
                                <div align="center">
                                    <asp:Button ID="btnAdd" runat="server" 
                                     CssClass="savebtn" OnClick="btnAdd_Click" OnClientClick="return SendMsg();">
                                    </asp:Button><font face="宋体">&nbsp;</font>
                                    <asp:Button ID="btnCancel" runat="server"  CssClass="returnbtn" OnClick="btnCancel_Click">
                                    </asp:Button></div>
                          </td>
                        </tr>
                  </table>
                </td>
            </tr>
      </table>
   <div style=" display:none">    <uc1:CopyRight ID="CopyRight1" runat="server" />
    <uc2:checkright ID="checkright1" runat="server" /></div>
   <script type="text/javascript">
    function NextStep()
    {
        var lbxed =  document.getElementById("selerpeople"); 
        var uid="" ;
        for(var i=0;i<lbxed.length;i++)
        {
            uid+=lbxed.options[i].value+",";
        }
        uid=uid.substring(0,uid.length-1);
        if(uid!="")
        {
            document.getElementById("trSelect").style.display="none";
            document.getElementById("trMessage").style.display="block";
            document.getElementById("trNext").style.display="none";
            document.getElementById("trSave").style.display="block";
             return false;
        }
        else
        {
            alert("请先选择接收短信的人员");
            return false;
        }
    }
   function Validform()
   {
      
   }
   
   function BindDropGroup()
   {
       
        
        var dropDownList = document.getElementById("droptest_dropParent");
        var gno = dropDownList.options[dropDownList.selectedIndex].value; 
        //var gno = $("#droptest_dropParent option:selected").val(); 
            
        $.post("../../data/SysRole.aspx",{gno:""+gno+""},function(data){$("#dropGroup").empty(); $("#dropGroup").append(data); });
        
   }
  function BindUserSubScript()
  {
        var dropDownList = document.getElementById("droptest_dropParent");
        var gno = dropDownList.options[dropDownList.selectedIndex].value;
        
        var dropGroup = document.getElementById("dropGroup");
        var groupName =  dropGroup.options[dropGroup.selectedIndex].value;
        
        $.post("../../data/SysUsers.aspx",{gno:""+gno+"",rid:""+groupName+""},function(data){$("#selepeople").empty(); $("#selepeople").append(data); });
        return false;
  }
  function selectpeople(){
	var hasselect;
	var newline,str,i,folderid,foldername,j,oo,oo1;
	var dmlArray=new Array();
	var ts;
	var lbx = document.getElementById("selepeople");
	var lbxed =  document.getElementById("selerpeople");
	j=lbx.length-1;
	
	for(i=j;i>-1 ;i--){//是否选择
		if(lbx.options[i].selected){
			hasselect=true;
			folderid   = lbx.options[i].value;
			foldername = lbx.options[i].text;
			oo1=document.createElement('OPTION') ;
			oo1.text=foldername;
			oo1.value=folderid;
			
			if(lbxed.length>0)
			{
			    var temp=0;
			 for(var w = lbxed.length-1;w>-1;w--)
			    {
			        
			        if(lbxed.options[w].value==folderid)
			        {
			           temp++;
			        }
			       
			    }
			    if(temp>0)
			    {
			         alert("已经存在此用户了！");
			    }
			    else
			    {
			         lbxed.add (oo1) ;
			        lbx.remove (i);
			    }
			}
			else
			{
			    lbxed.add (oo1) ;
			        lbx.remove (i);
			}
			   
			}
							
		
	}
	if (hasselect){
	}else{
		alert("请选择人员");
		return false;
	}
		
}
function selectallpeople(){
	var newline,str,i,folderid,foldername,j,oo,oo1,k;
	var dmlArray=new Array();
	var lbx = document.getElementById("selepeople");
	var lbxed =  document.getElementById("selerpeople");
	k=0;
	j=document.getElementById("selepeople").length-1;	
	for(i=j;i>-1 ;i--){
		hasselect=true;
		folderid   = document.getElementById("selepeople").options[i].value;
		foldername = document.getElementById("selepeople").options[i].text;
		oo1=document.createElement('OPTION') ;
		oo1.text=foldername;
		oo1.value=folderid;
			if(lbxed.length>0)
			{
			    var temp=0;
			 for(var w = lbxed.length-1;w>-1;w--)
			    {
			        
			        if(lbxed.options[w].value==folderid)
			        {
			           temp++;
			        }
			       
			    }
			    if(temp>0)
			    {
			         //
			    }
			    else
			    {
			         lbxed.add (oo1) ;
			        lbx.remove (i);
			    }
			}
			else
			{
			    lbxed.add (oo1) ;
			        lbx.remove (i);
			}
		//str="insert into orgpeoplerole(id,roleno) values("+folderid+","+window.selerole.value  +")";
		//dmlArray[k]=str;
		k++;
	}
	//var ts=obj.executeSql(dmlArray);
	//if(ts=='0'){
		
	//}
	//else alert(ts);						
}

function cancelpeople(){
	var hascancel;
	var newline,str,i,folderid,foldername,j,oo,oo1;
	var dmlArray=new Array();
	var lbx = document.getElementById("selepeople");
	var lbxed =  document.getElementById("selerpeople");
	var ts;
	j=lbxed.length-1;
	
	for(i=j;i>-1 ;i--){//是否选择
		if(lbxed.options[i].selected){
			hascancel=true;
			folderid   = lbxed.options[i].value;
			foldername = lbxed.options[i].text;
			oo1=document.createElement('OPTION') ;
			
			oo1.text=foldername;
			oo1.value=folderid;
			lbxed.remove (i);
			lbx.add (oo1) ;
		}
	}
	if (hascancel){
	}else{
		alert("请选择人员");
		return false;
	}
	
}
function cancelallpeople(){
	var hascancel;
	var newline,str,i,folderid,foldername,j,oo,oo1,k;
	var dmlArray=new Array();
	var lbx = document.getElementById("selepeople");
	var lbxed =  document.getElementById("selerpeople");
	var ts;
	j=lbxed.length-1;
	k=0;
	for(i=j;i>-1 ;i--){
		folderid   = lbxed.options[i].value;
		foldername = lbxed.options[i].text;
		oo1=document.createElement('OPTION') ;
		oo1.text=foldername;
		oo1.value=folderid;
		lbxed.remove (i);
		lbx.add (oo1) ;
		
		k++;
	}
						
}
function SendMsg()
{
       var dropDownList = document.getElementById("droptest_dropParent");
        var gno = dropDownList.options[dropDownList.selectedIndex].value;
    var lbxed =  document.getElementById("selerpeople"); 
    var uid="" ;
    for(var i=0;i<lbxed.length;i++)
    {
        uid+=lbxed.options[i].value+",";
    }
    uid=uid.substring(0,uid.length-1);
    if(document.getElementById("txtMsg").value=="")
    {
        alert("请输入短信内容!");
        document.getElementById("txtMsg").focus();
        return false;
    }
    if(uid!="")
    {
        $.post("../../data/SysSendM.aspx",{IDs:""+uid+"",content:""+document.getElementById("txtMsg").value+"",gno:""+gno+""},function(data){if(data=="1"){alert("发送成功！");}else if(data=="0"){alert("无用户");}else{alert("发送失败！");}});
    }
    else
    {
        alert("请选择用户！");
    }
    return false;
}
function checklen(obj){
    var lenE = obj.value.length;
    
    var lenC = 0;
    var CJK = obj.value.match(/[\u4E00-\u9FA5\uF900-\uFA2D]/g);
     
    if (CJK != null) lenC += CJK.length;
     
    tno.innerText = 60 - lenC - lenE ;
     
    if (tno.innerText < 0) {
   
    var tmp = 0
    
    var cut = obj.value.substring(0, 60);
    
    for (var i=0; i<cut.length; i++){
    tmp += /[\u4E00-\u9FA5\uF900-\uFA2D]/.test(cut.charAt(i)) ? 2 : 1;
    if (tmp > 60) break;
    }
    obj.value = cut.substring(0, i);
    }
}
    </script>

    </form>
</body>
</html>
